Skip to content

feat: add support regexp buffer boundary assertions - #65486

Open
Oleksandr Tarasiuk (a-tarasyuk) wants to merge 2 commits into
microsoft:mainfrom
a-tarasyuk:feat/proposal-regexp-buffer-boundaries
Open

Oleksandr Tarasiuk (a-tarasyuk) wants to merge 2 commits into
microsoft:mainfrom
a-tarasyuk:feat/proposal-regexp-buffer-boundaries

Conversation

@a-tarasyuk

Copy link
Copy Markdown
Contributor

Copilot AI balanced review requested due to automatic review settings November 13, 2026 19:01
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 13, 2026
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Nov 13, 2026
@typescript-automation

Copy link
Copy Markdown
Contributor

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

case 'A', 'z', 'Z':
if p.anyUnicodeMode {
p.incPos(1)
if p.scanner.languageVersion() < core.ScriptTargetESNext {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be in the "features" list? (I had thought that's where we put all the regexp version info)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I just wasn’t sure about moving LanguageFeature out of the checker to avoid importing from the scanner :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Er, I think i was just thinking of regExpFlagToFirstAvailableLanguageVersion no? I guess these aren't flags...

I didn't realize that actually we didn't check the other stuff at all, so I probably asked you for too much

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn’t use regExpFlagToFirstAvailableLanguageVersion because it seems to cover only flags, not assertions, so I decided to use a direct target check similar to

if p.scanner.languageVersion() < core.ScriptTargetES2018 {
p.error(diagnostics.Named_capturing_groups_are_only_available_when_targeting_ES2018_or_later, groupNameStart, p.pos()-groupNameStart)
}

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the regular-expression boundary assertion support.

No open issues 🎉

1 file not reviewed
  • tsc/internal/diagnostics/diagnostics_generated.go: Generated file
What changed in this PR

Adds native TypeScript compiler support for the proposed regular-expression buffer boundary assertions \A, \z, and \Z.

Changes:

  • Recognizes the assertions in Unicode (u/v) mode while preserving legacy identity escapes.
  • Requires ESNext and rejects direct quantification of the assertions.
  • Adds compiler tests and diagnostic/emission baselines for ES2026 and ESNext.
File Description
tsc/​testdata/​tests/​cases/​compiler/​regularExpressionAssertions.ts Tests assertions, target restrictions, quantifiers, and escape handling.
tsc/​testdata/​baselines/​reference/​compiler/​regularExpressionAssertions(target=esnext).js Records unchanged regex emission for ESNext.
tsc/​testdata/​baselines/​reference/​compiler/​regularExpressionAssertions(target=esnext).errors.txt Records invalid quantifier and escape diagnostics.
tsc/​testdata/​baselines/​reference/​compiler/​regularExpressionAssertions(target=es2026).js Records unchanged regex emission for ES2026.
tsc/​testdata/​baselines/​reference/​compiler/​regularExpressionAssertions(target=es2026).errors.txt Records target restrictions and syntax diagnostics.
tsc/​internal/​scanner/​regexp.go Recognizes assertions and enforces target and quantifier rules.
tsc/​internal/​diagnostics/​diagnostics_generated.go Registers the generated ESNext-only diagnostic.
tsc/​internal/​diagnostics/​diagnosticMessages.json Defines the ESNext-only diagnostic message.
tsc/​internal/​diagnostics/​diagnosticMessages.generated.json Adds the generated localization entry.

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the regular-expression buffer boundary assertion changes.

No open issues 🎉

1 file not reviewed
  • tsc/internal/diagnostics/diagnostics_generated.go: Generated file

Review effort: Balanced

@a-tarasyuk
Oleksandr Tarasiuk (a-tarasyuk) force-pushed the feat/proposal-regexp-buffer-boundaries branch from 15266c8 to 775e2f4 Compare November 13, 2026 20:54

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

3 participants